package com.user.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.user.entity.AdminMenu;
import com.user.mapper.AdminMenuMapper;
import com.user.service.AdminMenuService;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Service
public class AdminMenuServiceImpl extends ServiceImpl<AdminMenuMapper, AdminMenu> implements AdminMenuService {

    @Override
    public Set<String> getAdminMenuItems(Long userid) {
        Set<String> perms = new HashSet<String>();
        Integer id = Integer.valueOf(String.valueOf(userid));
        List<AdminMenu> list = baseMapper.getAdminMenuItems(id);
        for (AdminMenu adminMenu : list) {
            perms.addAll(Collections.singleton(adminMenu.getRealm()));
        }
        return perms;
    }
}
